9fb6c9cc27264e41118922f3135cfb0277739911,src/test/java/com/couchbase/client/core/config/refresher/CarrierRefresherTest.java,CarrierRefresherTest,shouldProposeConfigFromTaintedPoller,#,70
Before Change
when(config.nodes()).thenReturn(nodeInfos);
ByteBuf content = Unpooled.copiedBuffer("{\"config\": true}", CharsetUtil.UTF_8);
when(cluster.send(any(GetBucketConfigRequest.class))).thenReturn(Observable.just(
(CouchbaseResponse) new GetBucketConfigResponse(
ResponseStatus.SUCCESS, KeyValueStatus.SUCCESS.code(),
"bucket",
content,
InetAddress.getByName("localhost")
)
));
refresher.markTainted(config);
After Change
final AtomicReference<ByteBuf> bufRef = new AtomicReference<ByteBuf>(null);
when(cluster.send(any(GetBucketConfigRequest.class)))
.thenAnswer(new Answer<Observable<GetBucketConfigResponse>>() {
@Override
public Observable<GetBucketConfigResponse> answer(InvocationOnMock invocation) throws Throwable {
ByteBuf content = Unpooled.copiedBuffer("{\"config\": true}", CharsetUtil.UTF_8);
ByteBuf oldContent = bufRef.getAndSet(content);
if (oldContent != null) {
assertEquals(0, oldContent.refCnt());
}
GetBucketConfigResponse response = new GetBucketConfigResponse(
ResponseStatus.SUCCESS, KeyValueStatus.SUCCESS.code(),
"bucket",
content,
InetAddress.getByName("localhost"));
return Observable.just(response);
}
});
refresher.markTainted(config);